package L_5_7;

import javax.swing.*;

public class Computer {
    public void powerOn () {
        System.out.println ("打开电脑");
    }

    public void powerOff () {
        System.out.println ("关闭电脑");
    }

    void useDevice (Iusb iusb) {
        iusb.deviceOpen ();
        if (iusb instanceof Mouse) {
            Mouse m = (Mouse) iusb;
            m.click ();
        } else if (iusb instanceof keyBoard) {
            keyBoard k = (keyBoard) iusb;
            k.input ();
        }

        iusb.deviceClose ();
    }
}
